from django.conf.urls import url
from . import views
from rest_framework_jwt.views import obtain_jwt_token
from rest_framework.routers import DefaultRouter

urlpatterns = [
    url(r'^usernames/(?P<username>\w{5,20})/count/$',views.CheckUsernameView.as_view()),
    url(r'^phones/(?P<mobile>1[345789]\d{9})/count/$',views.CheckMobileView.as_view()),
    url(r'^$',views.RegisterUserView.as_view()),
    # url(r'^auths/$', obtain_jwt_token),
    url(r'^auths/$', views.UserObtainJSONWebToken.as_view()),
    url(r'^infos/$', views.UserInfoView.as_view()),
    url(r'^emails/$', views.EmailSendView.as_view()),
    url(r'^emails/verification/$', views.EmailActiveView.as_view()),
    # url(r'^addresses/$', views.AddressView.as_view({"get":"list","post":"create"})),

    url(r'^test/(?P<name>.+)/(?P<age>\d+)/$',views.TestView.as_view()),
    url(r'^browerhistories/$',views.UserBrowerHistoryView.as_view()),
    url(r'^orders/$',views.UserOrdersView.as_view()), #获取用户订单

    url(r'^accounts/(?P<username>\w{5,20})/sms/token/$',views.GetName.as_view()),
    url(r'^accounts/(?P<username>\w{5,20})/password/token/$',views.VerifySmscode.as_view()),
    url(r'^sms_codes/$',views.Sendsmscode.as_view()),
    url(r'^(?P<pk>\d+)/password/$',views.ResetPassword.as_view()),

    # url(r'^(?P<pk>\d+)/password/$',views.ChangePasswordView.as_view()),
    url(r'^infos/$', views.UserInfoView.as_view()),

]

#1,创建DefaultRouter对象
router = DefaultRouter()

#2,注册视图集
router.register(r'addresses',views.AddressView,base_name="address")

#3,添加到urlpatterns
urlpatterns += router.urls